/*
 * @Author: xiaosihan 
 * @Date: 2024-08-18 03:12:06 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-08-19 21:57:00
 */

import { autorun } from "mobx";
import { ReactNode, useEffect, useRef, useState } from "react";
import rightPlaneStore from "../../RightPlane/rightPlaneStore";
import iconPNG from "./icon.png";
import icon2PNG from "./icon2.png";
import styles from "./showCommentBtn.module.less";
import rightPlaneDemoStore from "@views/pc/PartCollaborateDemo/RightPlaneDemo/rightPlaneDemoStore";


interface Iprops {
    children?: ReactNode
}

// 显示评论按钮
export default function ShowCommentBtn() {

    const dom = useRef<HTMLDivElement | null>(null);
    const [show, setShow] = useState(rightPlaneStore.show);

    const isDemo = (location.hash === "#/partCollaborateDemo");

    useEffect(() => {

    }, []);

    useEffect(() => autorun(() => {
        setShow((isDemo ? rightPlaneDemoStore : rightPlaneStore).show);
    }), []);

    return (
        <div
            className={styles.showCommentBtn}
            onClick={() => {
                const { show } = (isDemo ? rightPlaneDemoStore : rightPlaneStore);
                (isDemo ? rightPlaneDemoStore : rightPlaneStore).setShow(!show);
            }}
        >
            <img
                alt=""
                className={styles.icon}
                src={show ? icon2PNG : iconPNG}
            />
        </div>
    );

}